import request from '@/config/axios'
import type { Dayjs } from 'dayjs';

/** 发票管理信息 */
export interface BizInvoiceManagement {
          id: number; // 主键ID
          contractCode?: string; // 合同编号
          name?: string; // 名称
          taxIdNumber?: string; // 社会信用代码/纳税人识别号
          contactPhone: string; // 联系电话
          bankName: string; // 开户银行
          bankAccount: string; // 开户账号
          address: string; // 地址
          invoiceNumber: string; // 发票号码
          invoiceDate: string | Dayjs; // 开票日期
          invoiceType?: string; // 票种
          specificBusiness?: string; // 特定业务
          invoiceAmount?: number; // 发票金额
          taxRate?: number; // 税率
          taxAmount?: number; // 税金
          amountWithoutTax?: number; // 不含税金额
          remarks: string; // 备注
          sellerBank: string; // 销方银行
          updatedAt: string | Dayjs; // 更新时间
  }

// 发票管理 API
export const BizInvoiceManagementApi = {
  // 查询发票管理分页
  getBizInvoiceManagementPage: async (params: any) => {
    return await request.get({ url: `/invoice/biz-invoice-management/page`, params })
  },

  // 查询发票管理详情
  getBizInvoiceManagement: async (id: number) => {
    return await request.get({ url: `/invoice/biz-invoice-management/get?id=` + id })
  },

  // 新增发票管理
  createBizInvoiceManagement: async (data: BizInvoiceManagement) => {
    return await request.post({ url: `/invoice/biz-invoice-management/create`, data })
  },

  // 修改发票管理
  updateBizInvoiceManagement: async (data: BizInvoiceManagement) => {
    return await request.put({ url: `/invoice/biz-invoice-management/update`, data })
  },

  // 删除发票管理
  deleteBizInvoiceManagement: async (id: number) => {
    return await request.delete({ url: `/invoice/biz-invoice-management/delete?id=` + id })
  },

  /** 批量删除发票管理 */
  deleteBizInvoiceManagementList: async (ids: number[]) => {
    return await request.delete({ url: `/invoice/biz-invoice-management/delete-list?ids=${ids.join(',')}` })
  },

  // 导出发票管理 Excel
  exportBizInvoiceManagement: async (params) => {
    return await request.download({ url: `/invoice/biz-invoice-management/export-excel`, params })
  },
  getInvoiceItemList: async (id: string) => {
    return await request.get({ url: `/invoice/biz-invoice-management/getItems?id=` + id })
  },
}
